package com.cyj.dream.admin.contacts.enums;


import com.cyj.dream.admin.util.IsEmptyUtils;

import java.util.*;

/**
 * @Description: 客户信息业务类型枚举类
 * @BelongsProject: dream-DreamChardonnay
 * @BelongsPackage: com.dream.DreamChardonnay.constant.enums
 * @Author: ChenYongJia
 * @CreateTime: 2021-06-22 10:47
 * @Email: chen87647213@163.com
 * @Version: 1.0
 */
public enum ContactsBusinessTypesEnum {


    /**
     * 枚举参数
     */
    DELETE_MONTH(0, "软件开发"),
    DELETE_WEEKS(1, "策划"),
    DELETE_TODAY(2, "运营"),
    ;

    private Integer code;
    private String message;

    ContactsBusinessTypesEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * 根据 类型编码 来获取 描述信息
     *
     * @param code
     * @return
     */
    public static String getMessByCode(Integer code) {
        if (IsEmptyUtils.isEmpty(code)) {
            return null;
        }

        for (ContactsBusinessTypesEnum contactsBusinessTypesEnum : values()) {
            if (contactsBusinessTypesEnum.getCode().equals(code)) {
                return contactsBusinessTypesEnum.getMessage();
            }
        }
        throw new RuntimeException("没有找到对应的描述信息");
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static void main(String[] args) {
        List<Map<String, Object>> mapList = new ArrayList<>();
        Arrays.asList(ContactsBusinessTypesEnum.values()).forEach(day -> {
            Map<String, Object> map = new HashMap<>();
            map.put("key", day.getCode());
            map.put("value", day.getMessage());
            mapList.add(map);
        });
        System.out.println(mapList);

        System.out.println(ContactsBusinessTypesEnum.getMessByCode(0));
    }

}
